package com.haozi.config;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.setting.dialect.Props;
import com.haozi.constants.ConfigConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.nio.charset.Charset;

/**
 * @author zyh
 * @version 1.0
 * @date 2022/4/27 11:47 上午
 */
@Component
public class GlobalConfig {

    @Autowired
    private GlobalArgs globalArgs;

    private GlobalConfig() {
    }


    private Props props;


    public void init(){
        this.globalArgs = globalArgs;
        String configFile = globalArgs.getPropertie(ConfigConstant.CONFIG_FILE);
        props = new Props(configFile, CharsetUtil.UTF_8);
    }
    /**
     * 获取属性
     *
     * @param key
     * @return
     */
    public String getProperties(String key) {
        return props.getProperty(key);
    }


}
